package org.linlinjava.litemall.web.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.web.annotation.LogAnno;
import org.linlinjava.litemall.web.annotation.LoginShop;
import org.linlinjava.litemall.web.annotation.LoginUser;
import org.linlinjava.litemall.web.dto.WebCashSettlementDTO;
import org.linlinjava.litemall.web.service.WebCashSettlementService;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

@Api(tags = "pos现金结算API")
@RestController
@RequestMapping("/web/cash")
@RequiredArgsConstructor
public class WebCashSettlementController extends ResponseUtil {

    private final WebCashSettlementService webCashSettlementService;
    @ApiOperation("POS结算-「日中结算和下班结算都用这个接口」")
    @LogAnno
    @PostMapping("/entering")
    public Response enteringCashSettlement(@RequestBody WebCashSettlementDTO cashSettlement,
                                           @ApiIgnore @LoginUser Integer userId,
                                           @ApiIgnore @LoginShop Integer shopId){

        return webCashSettlementService.enteringCashSettlement(cashSettlement,userId,shopId);
    }

    @ApiOperation("POS下班结算的结算值")
    @LogAnno
    @GetMapping("/gotOff")
    public Response gotOff(@ApiIgnore @LoginUser Integer userId,
                           @ApiIgnore @LoginShop Integer shopId,
                           @RequestParam("deviceNo")String deviceNo){
        return webCashSettlementService.gotOff(userId,shopId,deviceNo);
    }

    @ApiOperation("POS日中结算的结算值")
    @LogAnno
    @GetMapping("/noon")
    public Response noon(@ApiIgnore @LoginUser Integer userId,
                         @ApiIgnore @LoginShop Integer shopId,
                         @RequestParam("deviceNo")String deviceNo){
        return webCashSettlementService.noon(userId,shopId,deviceNo);
    }


}
